package org.jeecg.modules.lab.notify.service.impl;

import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.lab.notify.entity.LabNotify;
import org.jeecg.modules.lab.notify.mapper.LabNotifyMapper;
import org.jeecg.modules.lab.notify.service.ILabNotifyService;
import org.jeecg.modules.lab.notify.vo.LabNotifyPage;
import org.jeecg.modules.lab.notify.vo.LabNotifyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 消息通知
 * @Author: jeecg-boot
 * @Date:   2023-11-08
 * @Version: V1.0
 */
@Service
public class LabNotifyServiceImpl extends ServiceImpl<LabNotifyMapper, LabNotify> implements ILabNotifyService {

    @Autowired
    private LabNotifyMapper labNotifyMapper;

    @Override
    public List<LabNotifyVo> listMonth(String date,String userId) {
        List<String> months = labNotifyMapper.queryMonth(date,userId);
        List<LabNotifyVo> vos = new ArrayList<>();
        months.forEach(e->{
            LabNotifyVo notifyVo = new LabNotifyVo();
            List<LabNotify> list = labNotifyMapper.queryByMonth(e,userId);
            if (list.size()!=0){
                notifyVo.setDateTime(e);
                notifyVo.setNotifyList(list);
                vos.add(notifyVo);
            }
        });
        return vos;
    }
    @Override
    public LoginUser byIdLogUser(String uerId) {

        return labNotifyMapper.byIdLogUser(uerId);
    }

    @Override
    public List<LabNotifyPage> listAppNotify(LoginUser loginUser) {
        String userId = loginUser.getId();
        String userName = loginUser.getRealname();
        String tId = loginUser.getTId();
        return labNotifyMapper.listAppNotify(userId,userName,tId);
    }
}
